00001
00002
00003
00004
00005
00006
00007
00008
00009
00010
00011
00012
00013
00014
00015 #ifndef EXPORTFXSHNT33_HPP_
00016 #define EXPORTFXSHNT33_HPP_
00017
00018 #include <iostream>
00019 #include <string>
00020 #include <vector>
00021 #include <map>
00022
00023 #include "gridpack/parallel/communicator.hpp"
00024 #include "gridpack/component/data_collection.hpp"
00025 #include "gridpack/parser/dictionary.hpp"
00026 #include "gridpack/network/base_network.hpp"
00027 #include "gridpack/export/base_export.hpp"
00028
00029 namespace gridpack {
00030 namespace expnet {
00031
00032 template <class _network>
00033 class ExportFxShnt33
00034 {
00035 public:
00036
00037
00038
00039
00040 explicit ExportFxShnt33(boost::shared_ptr<_network> network) :
00041 p_network(network), p_comm(network->communicator())
00042 {
00043 }
00044
00045
00046
00047
00048 virtual ~ExportFxShnt33(){}
00049
00050
00051
00052
00053
00054
00055
00056
00057 void writeFxShntBlock(std::ofstream &fout)
00058 {
00059 BaseExport<_network> exprt(p_comm);
00060 int me = p_comm.rank();
00061
00062 int nbus = p_network->numBuses();
00063 gridpack::component::DataCollection *data;
00064 int i, j;
00065 char buf[MAX_STRING_SIZE];
00066 std::vector<text_line> text_data;
00067 for (i=0; i<nbus; i++) {
00068 if (p_network->getActiveBus(i)) {
00069 data = p_network->getBusData(i).get();
00070 double rval;
00071 int ival;
00072 std::string sval;
00073 char *ptr;
00074 int nshnt = 0;
00075 data->getValue(SHUNT_NUMBER,&nshnt);
00076 for (j=0; j<nshnt; j++) {
00077 ptr = buf;
00078 ival = p_network->getOriginalBusIndex(i);
00079 data->getValue(SHUNT_BUSNUMBER,&ival,j);
00080 sprintf(ptr,"%d,",ival);
00081 ptr += strlen(ptr);
00082 data->getValue(SHUNT_ID,&sval,j);
00083 sprintf(ptr," \'%s\',",sval.c_str());
00084 ptr += strlen(ptr);
00085 ival = 1;
00086 data->getValue(SHUNT_STATUS,&ival,j);
00087 sprintf(ptr," %d,",ival);
00088 ptr += strlen(ptr);
00089 rval = 0.0;
00090 data->getValue(BUS_SHUNT_GL,&rval,j);
00091 sprintf(ptr," %f,",rval);
00092 ptr += strlen(ptr);
00093 rval = 0.0;
00094 data->getValue(BUS_SHUNT_BL,&rval,j);
00095 sprintf(ptr," %f\n",rval);
00096 text_line text;
00097 strcpy(text.text,buf);
00098 text.global_idx = p_network->getGlobalBusIndex(i);
00099 text.device_idx = j;
00100 text_data.push_back(text);
00101 }
00102 }
00103 }
00104 if (me == 0) {
00105 fout << "0 / END LOAD DATA, BEGIN FIXED SHUNT DATA" << std::endl;
00106 }
00107 exprt.writeDataBlock(fout, text_data);
00108 }
00109
00110 private:
00111 boost::shared_ptr<_network> p_network;
00112
00113 gridpack::parallel::Communicator p_comm;
00114 };
00115
00116 }
00117 }
00118
00119 #endif